package com.itcv.mybatis.demo.reflect;

import java.io.Serializable;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.util.Map;

public class MapperProxy<T> implements InvocationHandler, Serializable {

    private final Class<T> mapperInterface;

    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("这个代码什么时候执行呢"+method.getName());
        if (Object.class.equals(method.getDeclaringClass())) {
            return method.invoke(this, args);
        } else {
            return new MethodInvoker().invoke(proxy,method,args);
          //  return cachedInvoker(method).invoke(proxy, method, args, sqlSession);
        }
      //  return method.invoke(this, args);
    }

    public MapperProxy(Class<T> mapperInterface) {

        this.mapperInterface = mapperInterface;

    }
}
